home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Human Interface Toolbox / Tabs LDEF / AppleEvents.c next >
Encoding:
Text File  |  2000-09-28  |  2.8 KB  |  122 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        AppleEvents.c
  3.  
  4.     Contains:    Handlers for the 4 "required" events
  5.  
  6.     Written by: Chris White    
  7.  
  8.     Copyright:    Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/10/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24.  
  25.  
  26. // System Includes
  27.  
  28. #ifndef __APPLEEVENTS__
  29.     #include <AppleEvents.h>
  30. #endif
  31.  
  32.  
  33.  
  34.  
  35. // Application includes
  36.  
  37. #ifndef __BAREBONES__
  38.     #include "BareBones.h"
  39. #endif
  40.  
  41. #ifndef __PROTOTYPES__
  42.     #include "Prototypes.h"
  43. #endif
  44.  
  45.  
  46.  
  47.  
  48.  
  49. // Static Prototypes
  50. static pascal OSErr HandleOapp ( AEDescList* aevt, AEDescList* reply, long refCon );
  51. static pascal OSErr HandleQuit ( AEDescList* aevt, AEDescList* reply, long refCon );
  52. static pascal OSErr HandleOdoc ( AEDescList* aevt, AEDescList* reply, long refCon );
  53. static pascal OSErr HandlePdoc ( AEDescList* aevt, AEDescList* reply, long refCon );
  54.  
  55.  
  56.  
  57. #pragma segment Initialize
  58.  
  59. OSErr InstallAppleEventHandlers ( void )
  60. {
  61.     OSErr    theErr;
  62.     
  63.     
  64.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEOpenApplication, NewAEEventHandlerProc ( HandleOapp ), 0, false );
  65.     if ( theErr )    goto CleanupAndBail;
  66.  
  67.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerProc ( HandleOdoc ), 0, false );
  68.     if ( theErr )    goto CleanupAndBail;
  69.  
  70.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEPrintDocuments, NewAEEventHandlerProc ( HandlePdoc ), 0, false );
  71.     if ( theErr )    goto CleanupAndBail;
  72.  
  73.     theErr = AEInstallEventHandler ( kCoreEventClass, kAEQuitApplication, NewAEEventHandlerProc ( HandleQuit ), 0, false );
  74.     if ( theErr )    goto CleanupAndBail;
  75.     
  76.     
  77. CleanupAndBail:
  78.  
  79.     return theErr;
  80.     
  81. }    // InstallAppleEventHandlers
  82.  
  83.  
  84.  
  85. #pragma segment Core
  86.  
  87. static pascal OSErr HandleOapp ( AEDescList* aevt, AEDescList* reply, long refCon )
  88. {
  89.     #pragma unused(aevt,reply,refCon)
  90.     return errAEEventNotHandled;
  91. }
  92.  
  93.  
  94.  
  95. static pascal OSErr HandleOdoc ( AEDescList* aevt, AEDescList* reply, long refCon )
  96. {
  97.     #pragma unused(aevt,reply,refCon)
  98.     return errAEEventNotHandled;
  99. }
  100.  
  101.  
  102.  
  103. static pascal OSErr HandlePdoc ( AEDescList* aevt, AEDescList* reply, long refCon )
  104. {    
  105.     #pragma unused(aevt,reply,refCon)
  106.     return errAEEventNotHandled;
  107. }
  108.  
  109.  
  110.  
  111. static pascal OSErr HandleQuit ( AEDescList* aevt, AEDescList* reply, long refCon )
  112. {
  113.     #pragma unused(aevt,reply,refCon)
  114.     gQuit = true;
  115.     
  116.     return noErr;
  117. }
  118.  
  119.  
  120.  
  121.  
  122.